home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / ply15doc.zip / TEXTURE.TXT < prev   
Text File  |  1992-11-08  |  12KB  |  359 lines

  1.  
  2.                      Solid Texturing in Polyray
  3.                      Alexander Enzmann
  4.  
  5. This document describes how to go about defining and developing solid
  6. textures for the Polyray raytracer.
  7.  
  8. The "noise surface" is a general purpose 3D solid texturing operation.  The
  9. options specified in the declaration allow a great deal of control over the
  10. coloring of a surface and over the bumpiness of a surface.  The complexity
  11. and speed of rendering of the noise surface type lies between the standard
  12. shading model and the "special" surfaces.
  13.  
  14. Definitions:
  15.  
  16.    The terms "vexper" stands for a vector expression of some sort (like <0,0,1>
  17.    or 2*<3,1,1>, etc.) and "fexper" stands for a floating point expression of
  18.    some sort (like 1, 2.0 * (3 - 4), etc.)
  19.  
  20.    A color is defined by red, green, and blue values from zero to 1, inclusive.
  21.    A color can appear as a vector expression like: <1, 0, 0> (for red), or
  22.    if it is one of the defined colors (see color.doc) then the name of the
  23.    color can be used.
  24.  
  25. A noise surface declaration has the form:
  26.  
  27.  texture {
  28.    noise surface {
  29. // Standard shading model values
  30.      color vexper                        // Color to use for amb/diff/..
  31.      ambient fexper                      // Amount of ambient
  32.      diffuse fexper                      // Amount of diffuse
  33.      specular vexper, fexper             // Color and amount of highlights
  34.      transmission vexper, fexper, fexper // Color, amount, ior of transparency
  35.      reflection fexper                   // Amount of reflectivity
  36.      microfact kind angle                // Specular model and falloff angle
  37.      color_map(map_entries)              // Lookup table for surface color
  38.  
  39. // Solid texturing functions
  40.      position_fn index                   // Which position
  41.      position_scale fexper               // Scaling factor for position
  42.      turbulence fexper                   // Amount noise affects position
  43.      octaves fexper                      // # of octaves of noise
  44.      lookup_fn index                     // Which color lookup function
  45.  
  46. // Surface bumpiness/ripple modifiers
  47.      normal_fn index                     // Which type of bumpiness
  48.      bump_scale fexper                   // Bumpiness of the surface
  49.      frequency fexper                    // Frequency of ripples
  50.      phase fexper                        // Offset of ripple wavefronts
  51.      }
  52.    }
  53.  
  54. Not all of the components need to be specified.  If components are left out,
  55. then the associated effects will not be applied.  For example if "normal_fn"
  56. is not specified then there will be no modification of the normal to the
  57. surface - it will stay as smooth as it started.
  58.  
  59.  
  60.                               Color Maps
  61.  
  62. Each entry in a color map has the form:
  63.  
  64.    [start_value, end_value, start_color, end_color]
  65. or
  66.    [start_value, end_value, start_color, start_alpha, end_color, end_alpha]
  67.  
  68.  
  69. When Polyray looks for a color in a color map it starts with an index
  70. value generated by the 3D texturing function defined by the surface.  If this
  71. value is between "start_value" and "end_value", then a resulting color is
  72. calculated that is between "start_color" and "end_color".
  73.  
  74. It is also possible to specify transparency ("alpha") values for each color
  75. in the color map.  This value ranges from 0 (not transparent at all) to 1
  76. (fully transparent).  A color map that uses transparency would appear like
  77. this:
  78.  
  79.          color_map(
  80.             [-2,   0,   blue,  0.8, blue,  0.8]
  81.             [-1,   0.5, green, 0.5, green, 0.5]
  82.             [ 0.5, 1.0, green, 0.5, tan,   0]
  83.             [ 1.0, 1.7, tan,   tan]
  84.             [ 1.7, 2,   white, white])
  85.  
  86. Making use of the alpha value is a little more subtle than it may first appear.
  87. The reason for this is that during shading the "color" part is used for the
  88. ambient and diffuse shading, then the alpha is used to determine how much of
  89. the color "behind" the surface will be added to the final color.  Added to this
  90. is that the color coming from behind the surface is filtered by the surface
  91. color - if you have a transparent green in front of a transparent blue then you
  92. will not see anything through the two surfaces, all color would be filtered out.
  93.  
  94. In order to help with transparency in noise surfaces, it is possible to specify
  95. values for the "transmission" component of the shading.  If this part of the
  96. texture is defined, then the color part of the transmission will be used for
  97. the filter.  A typical declaration would be:
  98.  
  99.       transmission white, 1, 1
  100.  
  101. Which will prevent Polyray from filtering the transmitted light.  What you
  102. will get is the sum of the surface color and the color that is coming from
  103. behind the surface.
  104.  
  105.                   Solid Texturing Functions
  106.  
  107. The way the final color of the texture is decided is by calculating a floating
  108. point value using the following general formula:
  109.  
  110.    index = lookup_fn(position_scale * position_fn +
  111.                      turbulence * noise3d(P, octaves))
  112.  
  113. The index value that is calculated is then used to lookup a color from the
  114. color map.  This final color is used for the ambient, diffuse, reflection and
  115. transmission filters.  The functions that are currently available, with their
  116. corresponding indices are:
  117.  
  118. Position functions:
  119.    Index       Effect
  120.        1        x value in the object coordinate system
  121.        2        x value in the world coordinate system
  122.        3        Distance from the z axis
  123.        4        Distance from the origin
  124.        6        Distance around the y axis (from 0 -> 1, counterclockwise)
  125.     default:    0.0
  126.  
  127. Lookup functions:
  128.    Index       Effect
  129.        1        sawtooth function, result from 0 -> 1
  130.        2        sin function, result from 0->1
  131.        3        ramp function, result from 0->1
  132.     default:    no modification made
  133.  
  134. Definitions of these function numbers that make sense are:
  135.  
  136. define position_plain       0
  137. define position_objectx     1
  138. define position_worldx      2
  139. define position_cylindrical 3
  140. define position_spherical   4
  141. define position_radial      5
  142.  
  143. define lookup_plain    0
  144. define lookup_sawtooth 1
  145. define lookup_sin      2
  146. define lookup_ramp     3
  147.  
  148.  
  149.                   Normal Modifying Functions
  150.  
  151. define plain_normal  0
  152. define bump_normal   1
  153. define ripple_normal 2
  154. define dented_normal 3
  155.  
  156.  
  157.                         Marble-like Textures
  158.  
  159. // The standard sort of marble texture
  160. define white_marble
  161. texture {
  162.    noise surface {
  163.       color white
  164.       ambient 0.3
  165.       diffuse 0.8
  166.       specular 0.3
  167.       microfacet Reitz 5
  168.  
  169.       position_fn position_objectx
  170.       lookup_fn lookup_sawtooth
  171.       octaves 3
  172.       turbulence 3
  173.  
  174.       color_map(
  175.          [0.0, 0.8, <1, 1, 1>, <0.6, 0.6, 0.6>]
  176.          [0.8, 1.0, <0.6, 0.6, 0.6>, <0.1, 0.1, 0.1>])
  177.       }
  178.    }
  179.  
  180. // Nice blue agate texture
  181. define sapphire_agate
  182. texture {
  183.    noise surface {
  184.       ambient 0.5
  185.       diffuse 0.7
  186.  
  187.       position_fn position_objectx
  188.       position_scale 1.1
  189.       lookup_fn lookup_sawtooth
  190.       octaves 3
  191.       turbulence 2
  192.  
  193.       color_map(
  194.          [0.0, 0.3, <0, 0, 0.9>, <0, 0, 0.8>]
  195.          [0.3, 1,   <0, 0, 0.8>, <0, 0, 0.4>])
  196.       }
  197.    scale <0.5, 0.5, 0.5>
  198.    }
  199.  
  200.  
  201.                   Wood-like Textures
  202.  
  203. // Create a wood texture.  Concentric rings of color
  204. // are wrapped around the z-axis.  There is some turbulence
  205. // in order to keep the rings from looking too perfect.
  206. define light_wood <0.6, 0.24, 0.1>
  207. define median_wood <0.3, 0.12, 0.03>
  208. define dark_wood <0.05, 0.01, 0.005>
  209. define wooden
  210. texture {
  211.    noise surface {
  212. // Define the standard shading components
  213.       ambient 0.2
  214.       diffuse 0.7
  215.       specular white, 0.5
  216.       microfacet Reitz 10
  217.  
  218. // Define how coloring is applied
  219.       position_fn position_cylindrical   // Color lookup is rings about z-axis
  220.       position_scale 1                   // This affects spacing between rings
  221.       lookup_fn lookup_sawtooth          // Keep the lookup value from 0->1
  222.       octaves 1                          // Keep the turbulence smooth
  223.       turbulence 1                       // Keep rings from being too circular
  224.  
  225.       // Define how the colors change from ring to ring
  226.       color_map(
  227.          [0.0, 0.2, light_wood, light_wood]
  228.          [0.2, 0.3, light_wood, median_wood]
  229.          [0.3, 0.4, median_wood, light_wood]
  230.          [0.4, 0.7, light_wood, light_wood]
  231.          [0.7, 0.8, light_wood, median_wood]
  232.          [0.8, 0.9, median_wood, light_wood]
  233.          [0.9, 1.0, light_wood, dark_wood])
  234.       }
  235.    }
  236.  
  237.  
  238.                         Gradient Textures
  239.  
  240. // This is an example of a gradient texture.
  241. define mountain_colors
  242. texture {
  243.    noise surface {
  244.       ambient 0.2
  245.       diffuse 0.8
  246.       specular 0.2
  247.  
  248.       position_fn position_objectx
  249.       color_map(
  250.          [-128,   0, blue,  blue]
  251.          [   0,  20, green, green]
  252.          [  20,  40, green, tan]
  253.          [  40,  90, tan,   tan]
  254.          [  90, 128, white, white])
  255.       }
  256.  
  257.    // The texture is rotated 90 degrees so that is is applied along the
  258.    // y-axis rather than along the x-axis.  This is so that the coloring
  259.    // will correspond to height.
  260.    rotate <0, 0, 90>
  261.    }
  262.  
  263.  
  264.                   Generic Turbulent Textures
  265.  
  266. // Simple color map texture
  267. define whorl_texture
  268. texture {
  269.    noise surface {
  270.       color green
  271.       ambient 0.3
  272.       diffuse 0.8
  273.  
  274.       lookup_fn lookup_sawtooth
  275.       octaves 2
  276.       turbulence 2
  277.  
  278.       color_map(
  279.          [0.0, 0.3, green,   blue]
  280.          [0.3, 0.6, blue,    skyblue]
  281.          [0.6, 0.8, skyblue, orange]
  282.          [0.8, 1.0, orange,  red])
  283.       }
  284.    scale <0.5, 0.5, 0.5>
  285.    }
  286.  
  287.  
  288.                   Cloudy Sky Texture
  289.  
  290. // Defines a turbulent texture with colors that go from grey in
  291. // the middle of the clouds, white at the edges, and blue elsewhere.
  292. // To use it, make a big sphere (possibly squashing it so the top isn't
  293. // too far away), apply this texture with scaling values that spread
  294. // the clouds to the desired amount.
  295. define cloudy_sky
  296. texture {
  297.    noise surface {
  298.       ambient 0.9
  299.       diffuse 0
  300.       specular 0
  301.       turbulence 6.0
  302.       position_fn position_worldx
  303.       lookup_fn 1
  304.       octaves 4
  305.       color_map(
  306.      [0.0, 0.6, <0.4, 0.4, 0.4>, <1, 1, 1>]
  307.      [0.6, 0.8, <1, 1, 1>, <0.196078, 0.6, 0.8>]
  308.      [0.8, 1.0, <0.196078, 0.6, 0.8>, <0.196078, 0.6, 0.8>])
  309.       }
  310.    }
  311.  
  312.                      Ripple (wavy) Textures
  313.  
  314. An example of a texture that uses ripples is:
  315.  
  316. define blue_ripple
  317. texture {
  318.    noise surface {
  319. // Define the standard shading components
  320.       color <0.4, 0.4, 1.0>
  321.       ambient 0.3
  322.       diffuse 0.4
  323.       specular white, 0.7
  324.       reflection 0.5
  325.       microfacet Reitz 10
  326.  
  327. // Define how how the surface will be bumped
  328.       normal ripple_normal  // Make a wavy surface
  329.       frequency 100         // This results in fairly tight ripples
  330.       bump_scale 2          // Make reasonably large bumps
  331.       }
  332.    scale <10, 1, 10>
  333.    }
  334.  
  335. This sample combines a marble coloration with rippling:
  336.  
  337.    define ripple_marble_texture
  338.    texture {
  339.       noise surface {
  340.          color white
  341.          position_fn 1
  342.          lookup_fn 1
  343.          octaves 4
  344.          turbulence 3
  345.          normal 2
  346.          frequency 10
  347.          bump_scale 5
  348.          ambient 0.1
  349.          diffuse 0.5
  350.          specular 0.6
  351.          microfacet Reitz 10
  352.          color_map(
  353.             [0.0, 0.8, <1, 1, 1>, <0.6, 0.6, 0.6>]
  354.             [0.8, 1.0, <0.6, 0.6, 0.6>, <0.1, 0.1, 0.1>])
  355.          }
  356.       translate <-5, 0, 0>
  357.       }
  358.  
  359.